function updateCartCount(CartCnt) {
    $("#cartCount").text(CartCnt);

}

function addtoCart(cid) {

    $.ajax({
        url: '/user/cart/add?cid=' + cid,
        type: 'get',
        dataType: 'json',
        beforeSend: function() {
            loading = $.tipsBoxy({ type: "loading", mask: true, message: "提交数据中..." });
        },
        success: function(ret) {
            loading.cancel();
            if (ret.code == 0) {
                var msg = '<div class="d_d_gx lh25 mt25 mb30 f14 c_777">';
                msg += '<img class="img" src="http://res.ckimg.com/sites/www/v2/images/public/ico_ok_25x25.png">';
                msg += '<p>已加入购物车！</p>';
                msg += '<p class="f12"><a href="/user/cart" target="_blank">查看我的购物车>></a></p>';
                msg += '</div>';
                msg += '<p class="tc">';
                msg += '<a href="javascript:;" id="try_success_confirm" class="c_btn37a"><span>确 定</span></a>';
                msg += '</p>';
                var ajaxBox = $.ckBoxy({
                    content: msg,
                    title: "提示",
                    width: 338,
                    height: 236,
                    callback: function() {
                        $(".close").click(function() {
                            ajaxBox.cancel();
                        });
                        $("#try_success_confirm").live('click', function() {
                            ajaxBox.cancel();
                        });
                    }
                });

                updateCartCount(ret.num);
            }
        }
    });
}

$(function() {
    //立刻购买
    $("a.buyBtn").click(function() {

    });

    $("#addToCart").click(function() {
        var cid = '123';
        addtoCart(cid);
    });
});